const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
	transpileDependencies: true,
	publicPath: process.env.NODE_ENV === "production" ? process.env.VUE_PUBLIC_PATH : "./",
	devServer: {
		port: "9401",
		proxy: {
			'/api': {
				target: 'http://localhost:6082',
				ws: true,
				changeOrigin: true,
				pathRewrite: {
				  '^/api': '/'
				}
			},
		}
	},
	chainWebpack: config =>{
		//配置title
		config.plugin('html').tap(args => {
			args[0].title = "斌味十足";
			return args;
		})
		if (process.env.NODE_ENV === "production") {
			let date = new Date();
			let sign2 = ":";
			let year = date.getFullYear(); // 年
			let month = date.getMonth() + 1; // 月
			let day = date.getDate(); // 日
			let hour = date.getHours(); // 时
			let minutes = date.getMinutes(); // 分
			let seconds = date.getSeconds(); //秒
			let Timestamp = year + "-" + month + "-" + day + "/" + hour + ":" + minutes + ":" + seconds;
			config.output.filename(`js/[name].js?v=${Timestamp}`).end();
			config.output.chunkFilename(`js/[name].js?v=${Timestamp}`).end();
			config.plugin("extract-css").tap(() => [
				{
					filename: `css/[name].css?v=${Timestamp}`,
					chunkFilename: `css/[name].css?v=${Timestamp}`,
				},
			]).end();
		}
	}
})
